%% phase transition
% Fig 3
figure
cc=[ 0.0549    0.2706    0.6275
    0.9020         0    0.0627
    0.0980    0.5412    0.1843
    0.8941    0.2314    0.5333
    0.9647    0.3294    0.0510
    0.0941    0.5294    0.9098
    0.5686    0.7490    0.1020
    0.9882    0.7098    0.0588
    0.1020    0.5686    0.4745];
load('./data/DDfromTensor.mat')
Expression2=Expression1;
load('./data/DDfromCurvature.mat')

% first point from Fig1CD2AB.m, others from FigS15to20.m
x_expt_G=[0,0.25,0.45,0.6,0.825,1,sqrt(2)]*sqrt(2);
y_expt_G=[0.986,1.01,1.03,1,0.37,0.23,0.11];
dy_expt_G=[0.035,0.05,0.08,0.14,0.03,0.03,0.01];

% first point from Fig2CDS14.m, others from FigS21to27.m
x_expt_B=[0,0.35,0.5,0.65,0.9,1.2,sqrt(2),1.7]*sqrt(2);
y_expt_B=[1.11,0.89,0.90,0.93,-0.31,-0.30,-0.27,-0.20];
dy_expt_B=[0.03,0.05,0.07,0.42,0.07,0.02,0.01,0.01];

hold on
% plot experiments first so their legends show up on top
errorbar(x_expt_B,y_expt_B,dy_expt_B,'s','MarkerSize',14,'LineWidth',2,'Color',cc(2,:),'MarkerFaceColor',cc(2,:));
errorbar(x_expt_G,y_expt_G,dy_expt_G,'s','MarkerSize',14,'LineWidth',2,'Color',cc(1,:),'MarkerFaceColor',cc(1,:));

% theory curve for B
Expp1_x=Expression1(:,1);Expp1_y=(Expression1(:,2));
plot(Expp1_x(1:2:40),Expp1_y(1:2:40),'MarkerSize',7,'LineWidth',2.5,'Color',cc(8,:),'HandleVisibility','off');
plot(Expp1_x(40+6:2:end),Expp1_y(40+6:2:end),'MarkerSize',7,'LineWidth',2.5,'Color',cc(8,:));

% simulated curve for G
Expp2_x=Expression2(:,1);Expp2_y=Expression2(:,2);
plot(Expp2_x(1:2:40),Expp2_y(1:2:40),'^-','MarkerSize',7,'LineWidth',2,'Color',cc(3,:),'HandleVisibility','off');
plot(Expp2_x(40+6:2:end),Expp2_y(40+6:2:end),'^-','MarkerSize',7,'LineWidth',2,'Color',cc(3,:));

% bring the experiment data points on top
errorbar(x_expt_B,y_expt_B,dy_expt_B,'s','MarkerSize',14,'LineWidth',2,'Color',cc(2,:),'MarkerFaceColor',cc(2,:),'HandleVisibility','off');
errorbar(x_expt_G,y_expt_G,dy_expt_G,'s','MarkerSize',14,'LineWidth',2,'Color',cc(1,:),'MarkerFaceColor',cc(1,:),'HandleVisibility','off');

xlabel('B_z/H_0','LineWidth',4);
ylabel('Observables','LineWidth',4);
set(gca,'FontSize',18);
box off;
xlim([0,3]);ylim([-0.6,1.5]);
set(gca,'XTick',[0:.5:3])
%lgd=legend('$$\mathcal{DD}$$ experiment','$$\mathcal{O}_\mathcal{D}$$ experiment','$$\mathcal{O}_\mathcal{D}$$ simulation','$\vert \mathcal{DD}\vert$ simulation');
lgd=legend('$$\mathcal{B}$$ experiment','$$\mathcal{G}$$ experiment','$$\mathcal{B}$$ theory','$$ \mathcal{G}$$ simulation');
lgd.FontSize=14;
set(lgd,'Interpreter','latex');